<cfcomponent extends="Controller" output="false">
	
	<!--- -player-results/index --->
	<cffunction name="index">
		<cfset playerresults = model("PlayerResult").findAll()>
	</cffunction>
	
	<!--- -player-results/show/key --->
	<cffunction name="show">
		
		<!--- Find the record --->
    	<cfset playerresult = model("PlayerResult").findByKey(params.key)>
    	
    	<!--- Check if the record exists --->
	    <cfif NOT IsObject(playerresult)>
	        <cfset flashInsert(error="PlayerResult #params.key# was not found")>
	        <cfset redirectTo(action="index")>
	    </cfif>
			
	</cffunction>
	
	<!--- -player-results/new --->
	<cffunction name="new">
		<cfset playerresult = model("PlayerResult").new()>
	</cffunction>
	
	<!--- -player-results/edit/key --->
	<cffunction name="edit">
	
		<!--- Find the record --->
    	<cfset playerresult = model("PlayerResult").findByKey(params.key)>
    	
    	<!--- Check if the record exists --->
	    <cfif NOT IsObject(playerresult)>
	        <cfset flashInsert(error="PlayerResult #params.key# was not found")>
			<cfset redirectTo(action="index")>
	    </cfif>
		
	</cffunction>
	
	<!--- -player-results/create --->
	<cffunction name="create">
		
		
		<cfdump var="#params.playerResult#">
		<cfloop from="1" to="#StructCount(params.playerResult)#" index="i">
			<cfdump var="#params.playerResult[i]#" label="#i#">
			<cfset playerresult = model("PlayerResult").new(params.playerResult[i])>
			<cfif playerresult.save()>
			<cfelse>	
				<cfdump var="#playerresult.allErrors()#">
				<cfabort>		
			</cfif>
		</cfloop>
		
		<!--- Back to the Results --->
		<cfset redirectTo(back=true)>
	
	</cffunction>
	
	<!--- -player-results/update --->
	<cffunction name="update">
		
		<cfset playerresults = model("PlayerResult").findByKey(params.key)>
		<!--- Verify that the playerresult updates successfully --->
		<cfif playerresults.update(params.playerresult)>
			<cfset flashInsert(success="The playerresult was updated successfully.")>	           
		<!--- Otherwise --->
		<cfelse>
			<cfset flashInsert(error=errorMessagesFor("playerresults"))>
		</cfif>
		 <cfset redirectTo(back=true)>
	</cffunction>
	
	<!--- -player-results/delete/key --->
	<cffunction name="delete">
		<cfset playerresult = model("PlayerResult").findByKey(params.key)>
		
		<!--- Verify that the playerresult deletes successfully --->
		<cfif playerresult.delete()>
			<cfset flashInsert(success="The playerresult was deleted successfully.")>	
            <cfset redirectTo(action="index")>
		<!--- Otherwise --->
		<cfelse>
			<cfset flashInsert(error="There was an error deleting the playerresult.")>
			<cfset redirectTo(action="index")>
		</cfif>
	</cffunction>
	
</cfcomponent>
